import type { ProColumns } from '@ant-design/pro-components';
import type { ProductItem } from './data.d';
import request from '@/utils/request';

export const columns: ProColumns<ProductItem>[] = [
  {
    title: '商品名称',
    dataIndex: 'name',
    width: 200,
    formItemProps: {
      rules: [{ required: true, message: '此项为必填项' }],
    },
    search: {
      transform: (value) => ({ name: value }),
    },
  },
  {
    title: '商品主图',
    dataIndex: 'mainImage',
    width: 100,
    valueType: 'image',
    formItemProps: {
      rules: [{ required: true, message: '此项为必填项' }],
    },
    search: false,
  },
  // ... 其他列配置保持不变
  {
    title: '操作',
    valueType: 'option',
    width: 200,
    search: false,
    render: (text, record, _, action) => [
      <a
        key="editable"
        onClick={() => {
          action?.startEditable?.(record.id);
        }}
      >
        编辑
      </a>,
      <a
        key="delete"
        onClick={async () => {
          await handleDelete(record);
          action?.reload();
        }}
      >
        删除
      </a>,
    ],
  },
]; 